package com.cloudxingkong.dianyinke.NewTeacher.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.cloudxingkong.dianyinke.NewTeacher.bean.Likes;
import com.cloudxingkong.dianyinke.R;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * Created by ningfei on 2016/5/10.
 */
public class ZanGVAdapter extends BaseAdapter {
    private List<Likes> zanList;
    private Context context;

    public ZanGVAdapter(List<Likes> zanList, Context context) {
        this.zanList = zanList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return zanList==null?0:zanList.size();
    }

    @Override
    public Object getItem(int position) {
        return zanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView=View.inflate(context, R.layout.item_dd_gv,null);
            holder=new ViewHolder();
            holder.iv= (ImageView) convertView.findViewById(R.id.item_dd_touxiang);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }

        String avatarPath = zanList.get(position).getUserAvatar();
        ImageLoader.getInstance().displayImage(avatarPath,holder.iv);

        return convertView;
    }
    private class ViewHolder{
        ImageView iv;
    }
}
